-
Notifications
You must be signed in to change notification settings - Fork 18
Group trait overhaul
#52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
92e47e3 to
2c19262
Compare
2c19262 to
142714c
Compare
- `random_nonzero_scalar` -> `random_scalar` - `scalar_as_bytes` -> `serialize_scalar` - `scalar_invert` -> `invert_scalar`
b45ff4b to
aed6a04
Compare
`to_arr` -> `serialize_elem` `base_point` -> `base_elem` `is_identity` -> removed `identity` -> `identity_elem` `zero_scalar` -> hidden behind `cfg(test)`
aed6a04 to
c255d64
Compare
13379ad to
23950cb
Compare
34d5153 to
85e4e70
Compare
85e4e70 to
c2ebc48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great! A couple of minor comments.
| ($var:ident) => { | ||
| &$var | ||
| }; | ||
| pub(crate) fn i2osp_2(input: usize) -> Result<GenericArray<u8, U2>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this named i2osp_2? Do you perhaps just mean i2osp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named this i2osp_2 because i2osp was still alive and this one wasn't generic, it simply always used a size of 2. Later on it just happened that all instances of i2osp were replaced with i2osp_2 so it was left like this.
I think the naming is still appropriate as the official i2osp function takes a length, that one doesn't, it always uses a length of 2, which is the only thing needed in VOPRF.
| let $var = $var.chain(chain_skip!(__temp$(, $feed2)?)); | ||
| )+ | ||
| }; | ||
| pub(crate) fn i2osp_2_array<L: ArrayLength<u8> + IsLess<U256>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this named i2osp_2_array? Do you perhaps just mean i2osp_array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
| use crate::voprf::Mode; | ||
| use crate::Result; | ||
|
|
||
| pub(crate) const STR_HASH_TO_SCALAR: [u8; 13] = *b"HashToScalar-"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if neither the p256 or ristretto255 feature is enabled, then these strings won't get used. Perhaps we could either just make them pub, or cfg-if on the features?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna handle this in a follow-up when we actually remove the P-256 implementation and replace it with a generic one over traits of elliptic-curve, then they are always used.
|
Awesome, thanks! |
Replaces #49.
Groupconstraints to associated type:Elem.GroupforNistP256instead ofProjectivePoint.GroupforRistretto255, our own type, instead ofRistrettoPoint. This type is re-exported.SUITE_IDtou16.hash_to_scalarandhash_to_curvenot take iterators anymore in preparation of Improve API for hash2curve functions RustCrypto/traits#876. This included reverting a lot of convenience utilities. Maybe we will come up with alternatives in the future.expand_message_xmdin with some additional constraints according to the spec.HashToScalarimplementation.